<?php
/**
 * Created by PhpStorm.
 * User: FEIFEI
 * Date: 2018/7/27
 * Time: 15:07
 */
namespace App\Http\Controllers;
use App\Common\lib\Util;
use Illuminate\Http\Request;
class DataStatisticsController extends Controller{

    public function index(){


        return view('datastatistics.index');
    }


    public function index_v1(){





        return view('datastatistics.index_v1');
    }


    //总营业额
    public function totalIncome(Request $request){

        if(isset($request->date)){
            $url = "/api/clientuser/statistics/dailyIncome?date=".$request->date;
        }else{
            $url = "/api/clientuser/statistics/dailyIncome";
        }
        $response = Util::toCurl($url, [], 20);
        $data = json_decode($response, true);
        return $data;
//        var_dump($data);
    }


    //分类统计收入

    public function classification(Request $request){
        if(isset($request->startDate)){
            $url = "/api/clientuser/income/classification?startDate=".$request->startDate."&endDate=".$request->endDate;
        }else{
            $url = "/api/clientuser/income/classification";
        }
        $response = Util::toCurl($url, [], 20);
        $data = json_decode($response, true);
        return $data;
    }


    //推荐总人数
    public function reference(Request $request){

        if(isset($request->date)){
            $url = "/api/clientuser/statistics/reference?&date=".$request->date;
        }else{
            $url = "/api/clientuser/statistics/reference";
        }

        $response = Util::toCurl($url, [], 20);
        $data = json_decode($response, true);
        return $data;
//        var_dump($data);
    }


    //分类统计人数

    public function classificationPe(Request $request){
        if(isset($request->startDate)){
            $url = "/api/clientuser/reference/classification?startDate=".$request->startDate."&endDate=".$request->endDate;
        }else{
            $url = "/api/clientuser/reference/classification";
        }

        $response = Util::toCurl($url, [], 20);
        $data = json_decode($response, true);
        return $data;
    }




}